package com.haidechizi.leetcode;

public class _409_最长回文串 {

    public int longestPalindrome(String s) {
        int[] chars = new int[128];
        for (char cha : s.toCharArray()) {
            chars[cha]++;
        }
        int flag = 0;
        int length = 0;
        for (int value : chars) {
            if (value % 2 == 0) {
                length += value;
            } else {
                length += value - 1;
                flag = 1;
            }
        }
        return length + flag;

    }


}
